package com.example.exp_9;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;

public class MathService extends Service {
    public MathService() {
        super();
    }
    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return super.onStartCommand(intent, flags, startId);
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
    }
    @Override
    public IBinder onBind(Intent intent) {
        MyBinder myBinder = new MyBinder();
        return myBinder;
    }
    public class MyBinder extends Binder {
        public int getSum(int n) {
            int sum = 0;
            for (int i=1;i<n;i++) {
                sum+=i;
            }
            System.out.println(sum);
            return sum;
        }
    }
}